{layout name="layouts/admin" /}
{css href="/static/webuploader/css/webuploader.css" /}
{css href="/static/webuploader/css/style.css" /}
<!-- jQuery 2.1.4 -->
{js href="/static/admin/plugins/jQuery/jquery-1.9.1.min.js" /}
{js href="/static/webuploader/dist/webuploader.js" /}
{js href="/static/webuploader/dist/upload.js" /}
<div class="panel-heading">{$sponsor?"编辑":"添加"}赞助商</div>
<div class="panel-body">
    <form action="/sponsor/doAddSponsor" method="POST">
        <div class="box-body">
            <div class="form-group">
                <label>赞助商名</label>
                <input type="hidden" name="id" value="{$sponsor.id|default=0}"/>
                <input type="hidden" name="auditstatus" value="{$sponsor.audit_status|default=0}"/>
                <input type="text" name="spname" value="{$sponsor.sp_name|default=''}" class="form-control" placeholder="请输入赞助商名称">
            </div>
            <div class="form-group">
                <label>赞助商跳转形式</label>
                {foreach name="jumptypearr" item="item" key="k"}
                <input style="margin-left:10px;" type="radio" {$sponsor.jump_type==$k?'checked':''} value="{$k}" name="jumptype"/>&nbsp;{$item}
                {/foreach}

            </div>
            <div class="form-group">
                <label>赞助商跳转地址</label>
                <input type="text" name="jumpurl" value="{$sponsor.jump_url|default=''}" class="form-control" placeholder="请输入跳转地址">
            </div>

            <div class="form-group">
                <label>赞助商联系方式</label>
                <input type="text" name="spcontact" value="{$sponsor.sp_contact|default=''}" class="form-control" placeholder="请输入手机号或微信号">
            </div>
            <div class="form-group">
                <label>赞助商联系人</label>
                <input type="text" name="linkname" value="{$sponsor.link_name|default=''}" class="form-control" placeholder="请输入联系人">
            </div>
            <div class="form-group">
                <label>赞助商简介</label>
                <textarea name="spinfo" class="form-control" placeholder="请输入赞助商简介">{$sponsor.sp_info|default=''}</textarea>
            </div>

            <div class="form-group">
                <label>赞助商logo图片(<font color="red">更换logo前请先删除之前的图片</font>)</label>
                <input type="hidden" id="imgurls" name="spimg" value="{$sponsor.sp_img}"/>
                {if $sponsor.sp_img!=""}
                <div>
                    <div onmouseover="picyiru(this,0)" onmouseout="picyiru(this,1)"
                         style="float: left;margin-right: 10px;">
                        <img src="{$sponsor.sp_img}" style="width:100px;height:100px;"/>
                        <div class="picrem"
                             style="background: rgba(28, 28, 28, 0.8); position: absolute; height: 20px; width: 100px; margin-top: -25px; display: none;">
                            <div style="width:95px;text-align: right">
                                <a href="javascript:void(0)" onclick="delpic(this,{$sponsor.id},'{$sponsor.sp_img}')"><i
                                        class="fa fa-trash-o fa-lg"></i></a>
                            </div>
                        </div>
                    </div>
                    <div style="clear: both;"></div>
                </div>
                {/if}
                <div id="uploader">
                    <input type="hidden" name="imgfiletype" value="0" />
                    <div class="queueList">
                        <div id="dndArea" class="placeholder">
                            <div id="filePicker"></div>
                            <p>或将照片拖到这里，单次最多可选300张</p>
                        </div>
                    </div>
                    <div class="statusBar" style="display:none;">

                        <div class="info"></div>
                        <div class="btns">
                            <div id="filePicker2"></div>
                            <div class="uploadBtn">开始上传</div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-primary">确认保存</button>
            </div>
        </div>
    </form>
</div>

<script>
    function picyiru(obj, type) {
        if (type == 0) {
            $(obj).find('.picrem').show();
        } else {
            $(obj).find('.picrem').hide();
        }
    }

    function delpic(thisdata,obj, imgurl) {
        if (confirm('确定要删除此logo图么？请慎重操作!!!')) {
            $.ajax({
                type: "POST",
                url: "/sponsor/delPic",
                data: "id=" + obj + "&imgurl=" + imgurl,
                success: function (msg) {
                    if (msg == 0) {
                        var imgurls = $("#imgurls").val();
                        var newstr = imgurls.replace(imgurl, "");
                        $("#imgurls").val(newstr);
                        $(thisdata).parent().parent().parent().remove();
                    }

                }
            });
        }
    }

</script>